#!/bin/sh
set -e
BUILD="$(pwd)"
newline="
"

if test -f "$BUILD"/libass_options ; then
    IFS=$newline
    set -- $(cat "$BUILD"/libass_options) "$@"
    unset -v IFS
fi

OPTIONS="--enable-static --disable-shared"
if "$BUILD"/scripts/test-libmpv ; then
    OPTIONS="$OPTIONS --with-pic"
fi

case "$PKG_CONFIG_PATH" in
  '')
    export PKG_CONFIG_PATH="$BUILD/build_libs/lib/pkgconfig"
    ;;
  *)
    export PKG_CONFIG_PATH="$BUILD/build_libs/lib/pkgconfig:$PKG_CONFIG_PATH"
    ;;
esac

cd "$BUILD"/libass
# Later libass doesn't automatically run configure with autogen.sh anymore
./autogen.sh --prefix="$BUILD/build_libs" --libdir="$BUILD/build_libs/lib" $OPTIONS "$@"
./configure  --prefix="$BUILD/build_libs" --libdir="$BUILD/build_libs/lib" $OPTIONS "$@"

